﻿using System;
using OurDailyBread.Helpers;

namespace OurDailyBread.Model
{
    public class VerseDataService : IVerseDataService
    {
        public async void GetData(Action<Object, Exception> callback)
        {
            // Use this to connect to the actual data service
            try
            {
                App app = (App)OurDailyBread.App.Current;
                string getResults = await HttpService.Get(app.Context.RefVerseUri);
                VerseData verse = new VerseData();
                verse.Text = Util.ExtractVerseContent(getResults);
                callback(verse, null);
            }
            catch (Exception ex)
            {
                callback(null, ex);
            }
        }
    }
}